/*-----------------------------------------------------------------------------
	The contents of this file are subject to the Mozilla Public License
	Version 1.1 (the "License"); you may not use this file except in
	compliance with the License. You may obtain a copy of the License at
	http://www.mozilla.org/MPL/
	
	Software distributed under the License is distributed on an "AS IS"
	basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
	License for the specific language governing rights and limitations
	under the License.
	
	The Original Code is Fever Framework code.
	
	The Initial Developer of the Original Code is Romain Ecarnot.
	Portions created by Initial Developer are Copyright (C) 2006
	the Initial Developer. All Rights Reserved.
	
	Contributor(s):
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
-----------------------------------------------------------------------------*/

import com.bourre.data.libs.ConfigLoader;
import com.bourre.data.libs.IXMLToObjectDeserializer;

import fever.data.libs.FileDecrypter;
import fever.data.libs.SecureXMLToObject;

/**
 * <strong>Pixlib ConfigLoader</strong> extension allows to use 
 * secured ( encrypted ) xml file content.
 * 
 * <p>Decryption process is done by {@link fever.data.libs.FileDecrypter}<br />
 * You can take a look at all crypter implementations in {@code data.crypt} 
 * package.
 * 
 * {@code
 *   var oC : FileDecrypter = new FileDecrypter( RC4.getProcess(), 'encryptionKey' );
 *   
 *   var cLoader : SecureConfigLoader = new SecureConfigLoader( oC );
 *   cLoader.addEventListener( SecureConfigLoader.onLoadInitEVENT, this, _onLoad );
 *   cLoader.load( 'crypted.xml' );
 * }
 * 
 * @see fever.data.libs.FileDecrypter * @see fever.data.libs.SecureXMLToObject
 * 
 * @author Romain Ecarnot
 */
class fever.data.libs.SecureConfigLoader extends ConfigLoader
{
	//-------------------------------------------------------------------------
	// Public API
	//-------------------------------------------------------------------------
	
	/**
	 * Constructor.
	 * 
	 * <p>Use new {@link fever.data.libs.SecureXMLToObject} engine.
	 * 
	 * @param decrypter {@link fever.data.libs.FileDecrypter} decryption process 
	 * to use
	 * @param o Object wich receive xml parsing
	 * @param deserializer {@link com.bourre.data.libs.IXMLToObjectDeserializer} 
	 * use to parse xml data
	 */ 
	public function SecureConfigLoader( decrypter : FileDecrypter, config : Object, deserializer : IXMLToObjectDeserializer ) 
	{
		super( config, deserializer );
		
		if( decrypter )
		{
			setContent( new SecureXMLToObject( decrypter, _oConfig, deserializer ) );
		}
	}
}